package com.tjhzzx.danfossNiagaraCore.model.energy;


import com.tjhzzx.danfossNiagaraCore.enums.BEnergyCategoryType;
import com.tjhzzx.danfossNiagaraCore.enums.BTreeMenuItemType;
import com.tjhzzx.danfossNiagaraCore.model.menu.BTreeMenuItem;
import com.tjhzzx.danfossNiagaraCore.model.set.BEnergyCategory;

import javax.baja.sys.Flags;
import javax.baja.sys.Sys;
import javax.baja.sys.Type;
import javax.baja.util.BFolder;

/**
 * @author Luc
 * @version 1.0
 * @date 2022-09-21 9:51
 */
public class BEnergySettingTreeMenuItem extends BTreeMenuItem {

    public BEnergySettingTreeMenuItem() {
        String title = "参数录入";
        String nIcon = "profile";
        String pagePath = "/EnergySettingTreeMenuItem";
        setTitle(title);
        setNIcon(nIcon);
        setPagePath(pagePath);

        setTreeMenuItemType(BTreeMenuItemType.page);
        BEnergyCategory power = new BEnergyCategory();
        power.setTitle("能耗");
        power.setEnergyCategoryType(BEnergyCategoryType.power);
        power.setFlags(power.getSlot("energyCategoryType"), Flags.READONLY);
        BEnergyCategory gas = new BEnergyCategory();
        gas.setTitle("碳能");
        gas.setEnergyCategoryType(BEnergyCategoryType.gas);
        gas.setFlags(gas.getSlot("energyCategoryType"), Flags.READONLY);
        BEnergyCategory electricity = new BEnergyCategory();
        electricity.setTitle("电费");
        electricity.setEnergyCategoryType(BEnergyCategoryType.electricity);
        electricity.setFlags(electricity.getSlot("energyCategoryType"), Flags.READONLY);
        BEnergyCategory water = new BEnergyCategory();
        water.setTitle("水费");
        water.setEnergyCategoryType(BEnergyCategoryType.water);
        water.setFlags(water.getSlot("energyCategoryType"), Flags.READONLY);

        BFolder searchParamRoot = new BFolder();
        searchParamRoot.add("power", power);
        searchParamRoot.add("gas", gas);
        searchParamRoot.add("electricity", electricity);
        searchParamRoot.add("water", water);
        setSearchParamRoot(searchParamRoot);
        setTreeMenuItemType(BTreeMenuItemType.searchParams);
        this.setFlags(this.getSlot("pagePath"), Flags.READONLY);
        this.setFlags(this.getSlot("pxView"), Flags.READONLY);
        this.setFlags(this.getSlot("searchParamRoot"), Flags.READONLY);
    }

    @Override
    public Type getType() {
        return TYPE;
    }

    public static final Type TYPE = Sys.loadType(BEnergySettingTreeMenuItem.class);
}
